package com.QK.cnstudy;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TabHost;

public class StudyGroup_Activity extends TabActivity implements OnClickListener {

    private TabHost mTabHost;
    private RadioGroup radioGroup;

    private RadioButton workRadioButton;
    private RadioButton transRadioButton;
    private RadioButton wordRadioButton;

    private int workId;

    private Bundle bundle;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.study_group_);
        getView();

        bundle = getIntent().getExtras();
        workId = bundle.getInt("id");
        Intent workIntent = new Intent(this, WorkActivity.class);
        Intent transIntent = new Intent(this, TranslateActivity.class);
        Intent wordIntent = new Intent(this, WordActivity.class);
        workIntent.putExtras(bundle);
        wordIntent.putExtras(bundle);
        transIntent.putExtras(bundle);
        mTabHost.addTab(mTabHost.newTabSpec("work").setIndicator("work").setContent(workIntent));
        mTabHost.addTab(mTabHost.newTabSpec("trans").setIndicator("trans").setContent(transIntent));
        mTabHost.addTab(mTabHost.newTabSpec("word").setIndicator("word").setContent(wordIntent));

        workRadioButton.setOnClickListener(this);
        transRadioButton.setOnClickListener(this);
        wordRadioButton.setOnClickListener(this);

    }

    public void getView() {
        mTabHost = getTabHost();
        radioGroup = (RadioGroup) findViewById(R.id.tab_group);
        workRadioButton = (RadioButton) findViewById(R.id.work_radio_button);
        transRadioButton = (RadioButton) findViewById(R.id.trans_radio_button);
        wordRadioButton = (RadioButton) findViewById(R.id.word_radio_button);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.work_radio_button:
            mTabHost.setCurrentTabByTag("work");
            break;
        case R.id.trans_radio_button:
            mTabHost.setCurrentTabByTag("trans");
            break;
        case R.id.word_radio_button:
            mTabHost.setCurrentTabByTag("word");
            break;
        default:
            break;
        }

    }
}
